<template>
  <div class="count">
    <PublicHead></PublicHead>
    <div class="countBox">
      <div class="title">
        <div :class="{ active: isActive == 0 }" @click="totitle(0)">示范平台</div>
        <div :class="{ active: isActive == 1 }" @click="totitle(1)">示范基地</div>
        <div :class="{ active: isActive == 2 }" @click="totitle(2)">入驻机构</div>
      </div>
      <div class="content">
        <div class="item" v-for="(item, index) in qylist" :key="index">
          <div>{{ item.qyName }}</div>
          <p>2023-04-12</p>
        </div>

      </div>
      <div class="pages">
        <el-button @click="pervious">上一页</el-button>
        <el-pagination  @current-change="handleCurrentChange"
      :current-page="page"  :page-size="size" background
      layout=" pager" :total="total"  ref="pageGroup"></el-pagination>
      <el-button @click="next">下一页</el-button>
      <span>共{{ Math.ceil( total/size) }}页</span>
      </div>
    </div>
    <PublicFoot></PublicFoot>
  </div>
</template>

<script>
import PublicHead from '../components/PublicHead.vue'
import PublicFoot from '../components/PublicFoot.vue'
import { shenbao_qyname } from '../api/api'
export default {
  data() {
    return {
      isActive: 0,
      qylist: [],
      page: 1,
      size: 7,
      total: 0,
    }

  },
  methods: {
    //分页组件
    handleCurrentChange(currentPage) {
      this.page = currentPage
      this.qyname()
    },
    pervious() {
      this.$refs.pageGroup.prev()
    },
    next() {
      this.$refs.pageGroup.next()
    },
    totitle(index){
      this.isActive=index
      this.qyname()
    },
    qyname() {
      shenbao_qyname({ page: this.page, size: '7', type: this.isActive }).then((res) => {
        this.total = res.data.data.total
        this.qylist = res.data.data.records
      })
    }
  },
  mounted() {
    this.qyname()
  },
  watch: {
    page: {
      handler:function(newvalue, oldvalue) {
        console.log(newvalue);
        console.log(oldvalue);
        this.page = newvalue
      }
    },
    immediate: true,
    deep: true,

  },
  components: {
    PublicHead,
    PublicFoot,
  },
}
</script>

<style lang="scss" scoped>
.pages{
  display: flex;
  align-items: center;
  position: absolute;
  bottom: 5%;
  left: 50%;
  transform: translateX(-50%);
  span{
    margin-left: 10px;
    font-size: 14px;
  }
}
.count {
  width: 100%;
  display: flex;
  justify-content: center;
  flex-direction: column;
  align-items: center;

  .countBox {
    width: 1220px;
    height: 675px;
    background: #FFFFFF;
    box-sizing: border-box;
    padding: 30px 40px;
    position: relative;
    .title {
      display: flex;
      width: 100%;
      border-bottom: #E7E7E7 2px solid;

      div {
        width: 140px;
        height: 40px;
        line-height: 40px;
        text-align: center;
        background-color: #D9EBF8;
        border: 1px solid #AFDBFB;
        color: #0279C4;
        margin-right: 30px;
      }

      .active {
        background-color: #0097FF;
        color: white;
      }
    }

    .content {
      margin-top: 30px;

      .item {
        width: 1136px;
        height: 55px;
        background: #F5FAFD;
        display: flex;
        justify-content: space-between;
        align-items: center;
        box-sizing: border-box;
        padding: 0px 20px;
        margin-bottom: 10px;

        div {
          font-size: 16px;
          font-family: Microsoft YaHei;
          font-weight: bold;
          color: #4C4C4C;
        }

        p {
          margin: 0;
          height: 10px;
          font-size: 14px;
          font-family: Arial;
          font-weight: 400;
          color: #828282;
        }
      }
    }
  }
}</style>